package graph;

import java.util.*;

/**
 * Node type representing a sequential list of statements. The statements are saved
 * in an ordered list, so that order information is preserved
 * 
 * @author Habib
 *
 */
public class BlockNode extends Node
{
	/**
	 * Ordered list of statements
	 */
	List<Node> children;
	
	/**
	 * Creates a node with no statements
	 */
	public BlockNode()
	{
		children = new ArrayList<Node>();
	}
	
	/**
	 * Adds a statement
	 * 
	 * @param node
	 */
	public void addStatementNode(Node node)
	{
		children.add(node);
	}
	
	/**
	 * Get the Node representing a statement at position index
	 * 
	 * @param index
	 * @return
	 */
	public Node getStatementNode(int index)
	{
		return children.get(index);
	}
	
	/**
	 * Remove the Node at position index
	 * 
	 * @param index
	 * @return
	 */
	public Node removeStatementNode(int index)
	{
		return children.remove(index);
	}
	
	/**
	 * Returns an iterator which iterates over all statements in order
	 * 
	 * @return
	 */
	public ListIterator<Node> iterator()
	{
		return children.listIterator();
	}
	
	@Override
	public String toString()
	{
		return "block";
	}
}